package com.ltkj.system.api;

import com.ltkj.common.core.constant.ServiceNameConstants;
import com.ltkj.common.core.domain.R;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.system.api.domain.CommAttachment;
import com.ltkj.system.api.domain.CommAttachmentQueryVo;
import com.ltkj.system.api.domain.SysFile;
import com.ltkj.system.api.factory.RemoteFileFallbackFactory;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 文件服务
 * 
 * @author ruoyi
 */
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
public interface RemoteFileService
{
    /**
     * 上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);

    /**
     * 文件上传请求
     * 存入数据库,可压缩图片
     */
    @PostMapping("uploadAtta")
    public R<CommAttachment> uploadPlus(@RequestPart(value = "file") MultipartFile file,@RequestParam("zoom") String zoom,@RequestParam("infoCode") String infoCode, @RequestParam("infoId") Long infoId);

    /**
     * 文件上传请求,可不传业务主键
     * 存入数据库,可压缩图片
     * 返回业务数据
     */
    @PostMapping("uploadAttaData")
    public R<CommAttachment> uploadAttaData(@RequestPart(value = "file") MultipartFile file,@RequestParam("zoom") String zoom,@RequestParam("infoCode") String infoCode,  @RequestParam("infoId") Long infoId);

    /**
     * 业务id与附件id关联
     * @param
     * @param attaIds
     * @return
     */
    @PostMapping("updateAttaData")
    public AjaxResult updateAttaData(@RequestParam("infoId") Long infoId,@RequestParam("infoCode") String infoCode, @RequestParam("attaIds") String attaIds);

    /**
     * 删除附件
     * @param attaId
     * @return
     */
    @DeleteMapping("deletaAtta")
    public AjaxResult deletaAtta(Long attaId);

    /**
     * 删除附件,只删表数据,通过业务id和业务编码
     * @param
     * @return
     */
    @DeleteMapping("deletaAttaByInfo")
    public AjaxResult deletaAttaByInfo(@RequestParam("infoCode") String infoCode,  @RequestParam("infoId") Long infoId);

    /**
     * 多文件上传请求
     * 存入数据库,可压缩图片
     * 返回业务数据
     */
    @PostMapping("uploadAttaDataMore")
    public R<List<CommAttachment>> uploadAttaDataMore(@RequestPart(value = "files") List<MultipartFile> files,@RequestParam("zoom")  String zoom,@RequestParam("infoCode") String infoCode,  @RequestParam("infoId") Long infoId);

    /**
     * 根据业务id和code查询附件
     * @param infoId
     * @param infoCode
     * @return
     */
    @GetMapping("selectAtta")
    public List<CommAttachment> selectAtta(@RequestParam("infoId")Long infoId, @RequestParam("infoCode")String infoCode);

    /**
     * 根据附件id查询附件
     * @param attaId
     * @return
     */
    @GetMapping("selectAttaById")
    public CommAttachment selectAttaById(@RequestParam("attaId")Long attaId);

    /**
     * 根据多条业务id和一个code查询附件
     * @param commAttachmentQueryVo
     * @return
     */
    @PostMapping("selectAttaByInfoIds")
    R<List<CommAttachment>> selectAttaByInfoIds(@RequestBody CommAttachmentQueryVo commAttachmentQueryVo);

}
